package tyx.study.jsp.dao.imp;

import java.sql.ResultSet;
import java.util.List;

import tyx.study.jsp.dao.IEmpDao;
import tyx.study.jsp.javabean.Emp;

public  class EmpDaoImp extends BaseDao implements IEmpDao {
	
	private ResultSet rs;
	
	public  List<Emp> selectAll(){
		String sql="select * from emp order by eno";
		return getInstances(Emp.class, sql);
	}
	@Override
	public Emp selectByEname(String ename) {
		
		String sql="select * from emp where ename=?";
		return (Emp) getInstance(Emp.class, sql, ename);
		
	}
	@Override
	public int insert(Emp emp) {
		String sql="insert into Emp values(?,?,?,?,?)";
		return update(sql, emp.getEno(),emp.getEname(),emp.getEjob(),emp.getEhiredate(),emp.getEsalary());	
	}
	@Override
	public Emp selectByEno(Integer eno) {
	
		String sql="select * from emp where eno=?";
		return (Emp) getInstance(Emp.class, sql, eno);
	}
	@Override
	public int updateEmp(Emp emp) {
		String sql="update emp set ename=?, ejob=?,ehiredate=?,esalary=? where eno=?";
		return update(sql, emp.getEname(), emp.getEjob(), emp.getEhiredate(),emp.getEsalary(),emp.getEno());
	}
	@Override
	public int deleteEmp(Integer eno) {
	
		String sql="delete from emp where eno=?";
		return update(sql, eno);
	}
	
	
}
